import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';

/** 表单的字段 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'modelName',
      label: '模型名称',
      component: 'Input',
      componentProps: {
        placeholder: '请输入模型名称',
      },
      rules: 'required',
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'modelName',
      label: '模型名称',
      component: 'Input',
      componentProps: {
        placeholder: '请输入模型名称',
        allowClear: true,
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions['columns'] {
  return [
    { type: 'seq', title: '序号', width: 40 },
    {
      field: 'name',
      title: '模型名称',
    },
    {
      field: 'sizeString',
      title: '大小',
    },
    {
      field: 'modified_at',
      title: '创建时间',
      formatter: 'formatDateTime', // 使用Vben Admin内置的日期时间格式化器
    },
    {
      field: 'actions',
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}
